//
//  RealNameViewController.m
//  ZJControlsClass
//
//  Created by apple on 2024/10/27.
//

#import "RealNameViewController.h"
#import "ZJNTESLiveViewController.h"




@interface RealNameViewController ()

@property (nonatomic,strong) UILabel * msgLabel;
@property (nonatomic,strong) UIView * follewView;
@property (nonatomic,strong) UILabel * nameLabel;
@property (nonatomic,strong) UITextField * nameTextF;
@property (nonatomic,strong) UIView * nameV;

@property (nonatomic,strong) UILabel * careLabel;
@property (nonatomic,strong) UITextField * careTextF;
@property (nonatomic,strong) UIView * careV;

@property (nonatomic,strong) UILabel * phoneLabel;
@property (nonatomic,strong) UIImageView * faceImg;
@property (nonatomic,strong) UIImageView * reverseImg;

@property (nonatomic,strong) UIButton * canleBtn;
@property (nonatomic,strong) UIButton * nextBtn;


@end

@implementation RealNameViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    // gradient
    CAGradientLayer *gl = [CAGradientLayer layer];
    gl.frame = CGRectMake(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
    gl.startPoint = CGPointMake(0.76, 0.5);
    gl.endPoint = CGPointMake(0.24, 0.5);
    gl.colors = @[(__bridge id)COLOR_RGB(102, 151, 246).CGColor,(__bridge id)COLOR_RGB(50, 113, 237).CGColor];
    gl.locations = @[@(0), @(1.0f)];
    [self.view.layer addSublayer:gl];
    
    self.title = @"实名认证";
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    [self setUpUI];
    
    
}

-(void)setUpUI{

    [self.view addSubview:self.msgLabel];
    [self.view addSubview:self.follewView];
    [self.follewView addSubview:self.nameLabel];
    [self.follewView addSubview:self.nameTextF];
    [self.follewView addSubview:self.nameV];
    [self.follewView addSubview:self.careLabel];
    [self.follewView addSubview:self.careTextF];
    [self.follewView addSubview:self.careV];
    
//    [self.follewView addSubview:self.phoneLabel];
//    [self.follewView addSubview:self.faceImg];
//    [self.follewView addSubview:self.reverseImg];
    
    [self.follewView addSubview:self.canleBtn];
    [self.follewView addSubview:self.nextBtn];
    
    
    
    [self.msgLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.view.mas_centerX);
        make.top.equalTo(self.view).with.offset(StatusBarHeight);
        make.left.right.equalTo(self.view);
        make.height.equalTo(@(ALIGN_HEIGHT_PT(20)));
    }];
    [self.follewView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view);
        make.top.equalTo(self.msgLabel.mas_bottom).with.offset(ALIGN_HEIGHT_PT(26));
        make.bottom.equalTo(self.view.mas_bottom).with.offset(ALIGN_HEIGHT_PT(20));
    }];
    
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(self.follewView).with.offset(ALIGN_WIDTH_PT(20));
        make.height.equalTo(@(ALIGN_HEIGHT_PT(25)));
    }];
    [self.nameTextF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel.mas_left);
        make.top.equalTo(self.nameLabel.mas_bottom).with.offset(ALIGN_HEIGHT_PT(5));
        make.right.equalTo(self.follewView).with.offset(-ALIGN_WIDTH_PT(20));
        make.height.equalTo(@(ALIGN_HEIGHT_PT(40)));
    }];
    [self.nameV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameTextF.mas_left);
        make.right.equalTo(self.nameTextF.mas_right);
        make.top.equalTo(self.nameTextF.mas_bottom);
        make.height.equalTo(@(1));
    }];
    
    [self.careLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.nameV.mas_bottom).with.offset(ALIGN_HEIGHT_PT(20));
        make.left.equalTo(self.follewView).with.offset(ALIGN_WIDTH_PT(20));
        make.height.equalTo(@(ALIGN_HEIGHT_PT(25)));
    }];
    [self.careTextF mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLabel.mas_left);
        make.top.equalTo(self.careLabel.mas_bottom).with.offset(ALIGN_HEIGHT_PT(5));
        make.right.equalTo(self.follewView).with.offset(-ALIGN_WIDTH_PT(20));
        make.height.equalTo(@(ALIGN_HEIGHT_PT(40)));
    }];
    [self.careV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameTextF.mas_left);
        make.right.equalTo(self.nameTextF.mas_right);
        make.top.equalTo(self.careTextF.mas_bottom);
        make.height.equalTo(@(1));
    }];

//    [self.phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.careV.mas_bottom).with.offset(ALIGN_HEIGHT_PT(20));
//        make.left.equalTo(self.follewView).with.offset(ALIGN_WIDTH_PT(20));
//        make.height.equalTo(@(ALIGN_HEIGHT_PT(25)));
//    }];
//
//    [self.faceImg mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.phoneLabel.mas_bottom).with.offset(ALIGN_HEIGHT_PT(20));
//        make.left.equalTo(self.follewView).with.offset(ALIGN_WIDTH_PT(20));
//        make.size.equalTo(@(CGSizeMake(ALIGN_WIDTH_PT(240), 150)));
//    }];
//
//    [self.reverseImg mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(self.faceImg.mas_bottom).with.offset(ALIGN_HEIGHT_PT(10));
//        make.left.equalTo(self.follewView).with.offset(ALIGN_WIDTH_PT(20));
//        make.size.equalTo(@(CGSizeMake(ALIGN_WIDTH_PT(240), 150)));
//    }];
    
    [self.canleBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.follewView).with.offset(ALIGN_WIDTH_PT(12));
        make.bottom.equalTo(self.follewView.mas_bottom).with.offset(-ALIGN_HEIGHT_PT(40));
        make.size.equalTo(@(CGSizeMake((SCREEN_WIDTH - 36) / 2, ALIGN_HEIGHT_PT(45))));
    }];
    
    [self.nextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.follewView).with.offset(-ALIGN_WIDTH_PT(12));
        make.bottom.equalTo(self.follewView.mas_bottom).with.offset(-ALIGN_HEIGHT_PT(40));
        make.size.equalTo(@(CGSizeMake((SCREEN_WIDTH - 36) / 2, ALIGN_HEIGHT_PT(45))));
    }];
    
    
}

#pragma mark -- 点击事件

-(void)responsdTo_nextViewController{
    
    ZJNTESLiveViewController * vc = [ZJNTESLiveViewController new];
    vc.userNameStr = self.nameTextF.text;
    vc.idNoStr = self.careTextF.text;
    [self.navigationController pushViewController:vc animated:YES];
    
    
}




-(void)respondsTo_backViewController{
    [self.navigationController popViewControllerAnimated:YES];
}


#pragma mark -- 懒加载
-(UILabel *)msgLabel{
    if (!_msgLabel) {
        _msgLabel = [UILabel new];
        _msgLabel.text = @"①输入基本信息 > ②人脸识别";
        _msgLabel.textColor = [UIColor blackColor];
        _msgLabel.textAlignment = NSTextAlignmentCenter;
        _msgLabel.font = FONT12;
    }
    return _msgLabel;
}

-(UIView *)follewView{
    if (!_follewView) {
        _follewView = [UIView new];
        _follewView.backgroundColor = [UIColor whiteColor];
        _follewView.layer.cornerRadius = 20;
        _follewView.layer.masksToBounds = YES;
    }
    return _follewView;
}

-(UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [UILabel new];
        _nameLabel.text = @"姓名";
        _nameLabel.textColor = [UIColor blackColor];
        _nameLabel.textAlignment = NSTextAlignmentLeft;
        _nameLabel.font = FONT18;
    }
    return _nameLabel;
}

-(UITextField *)nameTextF{
    if (!_nameTextF) {
        _nameTextF = [UITextField new];
        _nameTextF.placeholder = @"请输入姓名";
        _nameTextF.textColor = [UIColor blackColor];
        _nameTextF.text = self.nameStr;
        _nameTextF.font = FONT14;
    }
    return _nameTextF;
}
-(UIView *)nameV{
    if (!_nameV) {
        _nameV = [UIView new];
        _nameV.backgroundColor = COLOR_RGB(217, 217, 217);
    }
    return _nameV;
}

-(UILabel *)careLabel{
    if (!_careLabel) {
        _careLabel = [UILabel new];
        _careLabel.text = @"身份证";
        _careLabel.textColor = [UIColor blackColor];
        _careLabel.textAlignment = NSTextAlignmentLeft;
        _careLabel.font = FONT18;
    }
    return _careLabel;
}

-(UITextField *)careTextF{
    if (!_careTextF) {
        _careTextF = [UITextField new];
        _careTextF.placeholder = @"从输入身份证";
        _careTextF.textColor = [UIColor blackColor];
        _careTextF.text = self.idNoStr;
        _careTextF.font = FONT14;
    }
    return _careTextF;
}
-(UIView *)careV{
    if (!_careV) {
        _careV = [UIView new];
        _careV.backgroundColor = COLOR_RGB(217, 217, 217);
    }
    return _careV;
}

-(UILabel *)phoneLabel{
    if (!_phoneLabel) {
        _phoneLabel = [UILabel new];
        _phoneLabel.text = @"身份证照片";
        _phoneLabel.textColor = [UIColor blackColor];
        _phoneLabel.textAlignment = NSTextAlignmentLeft;
        _phoneLabel.font = FONT18;
    }
    return _phoneLabel;
}

-(UIImageView *)faceImg{
    if (!_faceImg) {
        _faceImg = [UIImageView new];
        _faceImg.layer.borderColor = COLOR_RGB(215, 216, 217).CGColor;
        _faceImg.layer.borderWidth = 0.5;
        _faceImg.layer.cornerRadius = 10;
        _faceImg.layer.masksToBounds = YES;
    }
    return _faceImg;
}

-(UIImageView *)reverseImg{
    if (!_reverseImg) {
        _reverseImg = [UIImageView new];
        _reverseImg.layer.borderColor = COLOR_RGB(215, 216, 217).CGColor;
        _reverseImg.layer.borderWidth = 0.5;
        _reverseImg.layer.cornerRadius = 10;
        _reverseImg.layer.masksToBounds = YES;
    }
    return _reverseImg;
}


-(UIButton *)canleBtn{
    if (!_canleBtn) {
        _canleBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_canleBtn setTitle:@"取消" forState:(UIControlStateNormal)];
        [_canleBtn setTitleColor:COLOR_RGB(50, 113, 237) forState:UIControlStateNormal];
        _canleBtn.layer.cornerRadius = 5;
        _canleBtn.layer.masksToBounds = YES;
        _canleBtn.layer.borderColor = COLOR_RGB(50, 113, 237).CGColor;
        _canleBtn.layer.borderWidth = 0.5;
    }
    return _canleBtn;
}

-(UIButton *)nextBtn{
    if (!_nextBtn) {
        _nextBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_nextBtn setTitle:@"下一步" forState:(UIControlStateNormal)];
        _nextBtn.backgroundColor = COLOR_RGB(50, 113, 237);
        [_nextBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [_nextBtn addTarget:self action:@selector(responsdTo_nextViewController) forControlEvents:(UIControlEventTouchUpInside)];
        _nextBtn.layer.cornerRadius = 5;
        _nextBtn.layer.masksToBounds = YES;
    }
    return _nextBtn;
}


@end
